﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using Verse.AI;

namespace Miao.Stand
{
    public class CompProperties_CompToken : CompProperties
    {
        public CompProperties_CompToken()
        {
            compClass = typeof(CompToken);
        }
    }

    public class CompToken : ThingComp
    {
        public StandPawn owner;
        public Pawn self
        {
            get
            {
                return parent as Pawn;
            }
        }


        public override void CompTickRare()
        {
            base.CompTickRare();
            if (owner.standPower.CurLevel < 0.1f)//能量不足执行返回
            {
                if (self.Map != owner.Map)
                {
                    self.Destroy();
                    return;
                }
                ///返回替身母体
                if (!(self.CurJobDef == StandJobDefOf.ReturnToMaster))
                {
                    Messages.Message(self.NameShortColored + ("能量不足以维持消耗，正在返回主人".Translate()), MessageTypeDefOf.NegativeEvent);
                    Job job = JobMaker.MakeJob(StandJobDefOf.ReturnToMaster, owner);
                    self.jobs.StartJob(job, JobCondition.Succeeded);
                }
            }
        }
        public override void PostExposeData()
        {
            Scribe_References.Look<StandPawn>(ref owner, "owner");
            base.PostExposeData();
        }
    }
}
